

<div id="view_black">
	<div id="dashboard">
	  	<script language="javascript" type="text/javascript" defer>
			  window.onload = function(){
			     ConvertRowsToLinks("data_table1");
			 	 ConvertRowsToLinks("data_table2");
			 ConvertRowsToLinks("data_table3");
			 ConvertRowsToLinks("data_table4");
			 ConvertRowsToLinks("data_table5");
			  }

			  function ConvertRowsToLinks(xTableId){

			if(document.getElementById(xTableId) != null)
			{

			    	var rows = document.getElementById(xTableId).getElementsByTagName("tr");

			    for(i=0;i<rows.length;i++){

			      var link = rows[i].getElementsByTagName("a")
			      if(link.length == 1){
			        rows[i].onclick = new Function("document.location.href='" + link[0].href + "'");
					rows[i].onmouseover = new Function("this.className='highlight'; window.status='" + link[0].href + "';");
					rows[i].onmouseout = new Function("this.className='" + rows[i].className + "'; window.status='';");
			      }
			    }

			}

			  }

		</script>
		
	  <% if flash[:notice] %><h2 style="text-align:center"><%= flash[:notice] %></h2><% end %>
	
	<% if @user.is_publisher? %>
	<div id="dashboard_border">
		<div id="dashboard_bar"><h1>Pending Review</h1><div id="clear"></div></div>
	
		<table id="data_table1" class="dashboard_table">
			<tr>
				<td id="indicator"> </td><td>Page</td><td>Author</td><td>Section</td><td>Date</td>
			</tr>
			<% Page.pending_pages.each do |page|%>
				<tr id="data" class="<%= cycle('odd', 'even') %>">
					<td id="indicator"> </td>
					<td><%= link_to page.name, :controller => page.section.name, :action => :show, :id => page %></td>
					<td><%=page.owner.first_name%> <%=page.owner.last_name%></td>
					<td><%=Section.find(page.section_id).name%></td>
					<td><%=pretty_date(page.updated_at)%></td>
				</tr>
			<%end%>
		</table>
	</div>
	<%end%>
	<% if @user.is_editor? %>
	<div id="dashboard_border">
		<div id="dashboard_bar"><h1>My Documents</h1><div id="clear"></div></div>
	
		<table id="data_table2" class="dashboard_table">
			<tr>
				<td id="indicator"> </td><td>Page</td><td>Author</td><td>Section</td><td>Date</td>
			</tr>
			<% @user.get_my_pages.each do |page|%>
			
				<tr id="data" class="<%= cycle('odd', 'even') %>">
					<td id="indicator">
						
							<% if page.state == "draft" %>
								<%= image_tag "/images/ind_ylw.png" %>
							<% elsif page.state == "pending" %>
								<%= image_tag "/images/ind_red-1.png" %>
							<% elsif page.state == "published" %>
								<%= image_tag "/images/ind_grn.png" %>
							<% end %>
					</td>
					<td><%= link_to page.name, :controller => page.section.name, :action => :show, :id => page %></td>
					<td><%=page.owner.first_name%> <%=page.owner.last_name%></td>
					<td><%=Section.find(page.section_id).name%></td>
					<td><%= pretty_date(page.updated_at)%></td>
				</a>
				</tr>
				
			<%end%>
		</table>
	</div>
	<div id="dashboard_border">
		<div id="dashboard_bar"><h1>Comments on My Documents</h1><div id="clear"></div></div>
	
		<table id="data_table3" class="dashboard_table">
			<tr>
				<td id="indicator"> </td><td>Page</td><td>Author</td><td>Section</td><td>Date</td
			</tr>
			<% @user.get_my_pages.each do |page|
					page.my_comments.each do |comment|%>
				<tr id="data" class="<%= cycle('odd', 'even') %>">
					<td id="indicator"> </td>
					<td><%= link_to page.name, :controller => page.section.name, :action => :show, :id => page %></td>
					<td><%=comment.name%></td>
					<td><%=Section.find(page.section_id).name%></td>
					<td><%=pretty_date(comment.updated_at)%></td>
				</tr>
				<%end
			  end%>
		</table>
	</div>
	<%end%>	
	
	<% if @user.is_admin? %>
	  <div id="dashboard_border">
  		<div id="dashboard_bar"><h1>Recent Changed Documents</h1><div id="clear"></div></div>
	
  		<table id="data_table4" class="dashboard_table">
  			<tr>
  				<td id="indicator"> </td><td>Page</td><td>Author</td><td>Section</td><td>Date</td>
  			</tr>
  			<% Page.recent_pages.each do |page|%>
  				<tr id="data" class="<%= cycle('odd', 'even') %>">
  					<td id="indicator">
  							<% if page.state == "draft" %>
  								<%= image_tag "/images/ind_ylw.png" %>
  							<% elsif page.state == "pending" %>
  								<%= image_tag "/images/ind_red-1.png" %>
  							<% elsif page.state == "published" %>
  								<%= image_tag "/images/ind_grn.png" %>
  							<% end %>
  					</td>
  					<td><%= link_to page.name, :controller => page.section.name, :action => :show, :id => page %></td>
  					<td><%=page.owner.first_name%> <%=page.owner.last_name%></td>
  					<td><%=Section.find(page.section_id).name%></td>
  					<td><%=pretty_date(page.updated_at)%></td>
  				</tr>
  			<%end%>
  		</table>
  	</div>
  	
  	<div id="dashboard_border">
  		<div id="dashboard_bar"><h1>Recent Comments</h1><div id="clear"></div></div>
	
  		<table id="data_table5" class="dashboard_table">
  			<tr>
  				<td id="indicator"> </td><td>Page</td><td>Author</td><td>Section</td><td>Date</td>
  			</tr>
  			<% Comment.recent_comments.each do |comment| %>
  		    <% @page = comment.page %>
  				<tr id="data" class="<%= cycle('odd', 'even') %>">
  					<td id="indicator"> </td>
  					<td><%= link_to @page.name, :controller => @page.section.name, :action => :show, :id => @page %></td>
  					<td><%=comment.name%></td>
  					<td><%=Section.find(@page.section_id).name%></td>
  					<td><%=pretty_date(comment.updated_at)%></td>
  				</tr>
  			<%end%>
  		</table>
  	</div>
	<% end %>
	</div>
</div>